//
//  ViewController.m
//  block
//
//  Created by 李南江 on 15/9/5.
//  Copyright © 2015年 xiaomage. All rights reserved.
//

#import "ViewController.h"


typedef void (^FINISHED)();

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self loadData];
    
    [self loadData2:^{
        NSLog(@"执行回调");
    }];
    
    [self loadData3:@"lnj" finished:^{
         NSLog(@"执行回调");
    }];
}

- (void)loadData2:(void (^)())finished {
    NSLog(@"耗时操作");
    finished();
}


- (void)loadData3:(NSString *)name finished:(void (^)())finished
{
    NSLog(@"name = %@", name);
    finished();
}

- (void)loadData{
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        NSLog(@"耗时操作 %@", [NSThread currentThread]);
        
       dispatch_async(dispatch_get_main_queue(), ^{
           NSLog(@"回到主线程更新UI %@", [NSThread currentThread]);
       });
    });
}


@end
